events { worker_connections 1024; }

http {

    log_format upstreamlog '$server_name to: $upstream_addr {$request} '
    'upstream_response_time $upstream_response_time'
    ' request_time $request_time';

    server {
        listen 80;
        server_name localhost;
        location / {
            return 301 https://$host$request_uri;
        }
    }

    server {
        listen 443 ssl;
        server_name localhost;
        access_log /var/log/nginx/nginx-access.log upstreamlog;

        ssl_certificate /etc/nginx/certs/nginx-selfsigned.crt;
        ssl_certificate_key /etc/nginx/certs/nginx-selfsigned.key;

        location / {
            proxy_pass http://flask:5000;
        }
    }
}
